package com.lzp.customview.main

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.base.BaseActivity
import com.base.BaseFragment
import com.lzp.customview.LoadMoreRvActivity
import com.lzp.customview.R
import com.lzp.customview.adsorption.AdsorptionButtonActivity
import com.lzp.customview.bezier.BezierMainActivity
import com.lzp.customview.curve.CurveActivity
import com.lzp.customview.damp.demo.DampWrapperActivity
import com.lzp.customview.dashboard.DashBoardActivity
import com.lzp.customview.flowlayout.FlowLayoutActivity
import com.lzp.customview.load.LoadViewActivity
import com.lzp.customview.text.TextPathActivity
import com.lzp.customview.textview.WordWrapTextViewActivity
import com.lzp.customview.togglebtn.demo.ToggleButtonActivity
import com.lzp.customview.wave.VerticalWaveActivity
import kotlinx.android.synthetic.main.customview_fragment.*

/**
 * @describe:
 * @Author: lixiaopeng
 * @Date: 2020/3/24
 */
class CustomViewFragment : BaseFragment(), View.OnClickListener {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.customview_fragment, null)
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
    }

    override fun onDetach() {
        super.onDetach()
    }

    override fun initView() {
        super.initView()
        linearGradientTv.horizontalGradient(0xffffffff.toInt(), 0xffffff00.toInt(), true)
    }

    override fun setListener() {
        super.setListener()
        toggleBtn.setOnClickListener(this)
        dampRv.setOnClickListener(this)
        dampVp.setOnClickListener(this)
        indicator.setOnClickListener(this)
        halfCircle.setOnClickListener(this)
        linearGradientTv.setOnClickListener(this)
        roundRl.setOnClickListener(this)
        wordWrapTv.setOnClickListener(this)
        loadMoreRv.setOnClickListener(this)
        flowLayout.setOnClickListener(this)
        adsorptionBtn.setOnClickListener(this)
        loadView.setOnClickListener(this)
        curve.setOnClickListener(this)
        dashBoard.setOnClickListener(this)
        verticalWave.setOnClickListener(this)
        textPath.setOnClickListener {
            val intent = Intent(activity, TextPathActivity::class.java)
            startActivity(intent)
        }
        freshLayout.setOnRefreshListener {
            freshLayout.postDelayed({
                freshLayout.stopRefresh()
            },3000)
        }
        bezier.setOnClickListener {
            startActivity(Intent(activity,BezierMainActivity::class.java))
        }
    }

    override fun clearListener() {
        super.clearListener()
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.loadView -> {
                val intent = Intent(activity, LoadViewActivity::class.java)
                startActivity(intent)
            }
            R.id.toggleBtn -> {
                val intent = Intent(activity, ToggleButtonActivity::class.java)
                startActivity(intent)
            }
            R.id.dampRv -> {
                val intent = Intent(activity, DampWrapperActivity::class.java)
                startActivity(intent)
            }
            R.id.loadMoreRv -> {
                val intent = Intent(activity, LoadMoreRvActivity::class.java)
                startActivity(intent)
            }
            R.id.dampVp -> {
            }
            R.id.indicator -> {
            }
            R.id.halfCircle -> {
            }
            R.id.linearGradientTv -> {
            }
            R.id.roundRl -> {
            }
            R.id.dashBoard->{
                startActivity(BaseActivity.createIntent(activity, DashBoardActivity::class.java))
            }
            R.id.curve->{
                startActivity(BaseActivity.createIntent(activity, CurveActivity::class.java))
            }
            R.id.adsorptionBtn -> {
                startActivity(BaseActivity.createIntent(activity, AdsorptionButtonActivity::class.java))
            }
            R.id.flowLayout -> {
                startActivity(Intent(activity, FlowLayoutActivity::class.java))
            }
            R.id.wordWrapTv -> {
                val intent = Intent(activity, WordWrapTextViewActivity::class.java)
                startActivity(intent)
            }
            R.id.verticalWave->{
                val intent = Intent(activity, VerticalWaveActivity::class.java)
                startActivity(intent)
            }
        }
    }

}